#include <iostream>

using namespace std;

int main()
{
    int a[100];
    int i,j,n;
    cout<<"n=";cin>>n;
    for (i=0;i<n;i++)
    {
        std::cout<<"a["<<i<<"]=";std::cin>>a[i];
    }
    for (j=0;j<n;j++)
    {

    int el=a[0];
    for (i=0;i<n;i++)
    {
        a[i]=a[i+1];
    }
    a[n-1]=el;
    for (i=0;i<n;i++)
    {
        std::cout<<a[i];
    }
    std::cout<<endl;
    }
    //invers
    for (j=0;j<n;j++)
    {

    int el=a[n-1];
    for (i=n-1;i>=0;i--)
    {
        a[i]=a[i-1];
    }
    a[0]=el;
    for (i=0;i<n;i++)
    {
        std::cout<<a[i];
    }
    std::cout<<endl;
    }

    return 0;
}
